package cn.paul.junit;

import cn.paul.domain2.Person;
import cn.paul.domain4.User;
import cn.paul.mapper.PersonMapper;
import cn.paul.mapper4.UserMapper;
import cn.paul.utils.SqlSessionUtils;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by dell1 on 2017-06-23.
 */
public class One2OneTest {
    @Test
    public void test() {
        SqlSession sqlSession = SqlSessionUtils.getSession();
        //获得mapper接口的代理对象
        PersonMapper personMapper = sqlSession.getMapper(PersonMapper.class);
        Person person = personMapper.selectPersonById(1);
        System.out.println(person);
        System.out.println(person.getCard());
        sqlSession.commit();
        sqlSession.close();
    }
    @Test
    public void testUserSelect(){
        SqlSession sqlSession = SqlSessionUtils.getSession();
        UserMapper userMapper = sqlSession.getMapper(UserMapper.class);
        Map<String,Object> params = new HashMap();
//        params.put("username","aaa");
        params.put("password","111");
        User user = userMapper.selectUserWithParam(params);
        System.out.println(user);
    }
}
